

Dim doc
Set doc = application.ActiveDocument
GetUserLicence(doc)
doc.currentunit = 2
dim ObjFSO

main
sub main()
	dim usrlyr
	usrlyr = "DXF_TOP"
	application.gui.activeroutelayer=1
	doc.activeview.displaycontrol.UserLayer (usrlyr) = true
	doc.activeview.displaycontrol.global.UserLayerDisplayLevel(usrlyr)=1
	dim NColorObject
	set NColorObject = application.utility.NewColorPattern 
	With NColorObject
			.red = 255
			.green =255
			.blue =255
			.index =0
			.outline=false
			.Transparent=false
	end With
	set doc.activeView.DisplayControl.Global.UserLayerColor(usrlyr)=NColorObject
end sub



 
'#################################################################
'#################################################################
'#################################################################
'#################################################################
' Function to validate document
Private Function ValidateServer(docObj)
    Dim key, licenseServer, licenseToken
    key = docObj.Validate(0)
    Set licenseServer = CreateObject("MGCPCBAutomationLicensing.Application")
    licenseToken = licenseServer.GetToken(key)
    Set licenseServer = nothing
    'On Error Resume Next
    Err.Clear
    docObj.Validate(licenseToken)
    If Err Then
        ValidateServer = 0    
    Else 
        ValidateServer = 1
    End If
End Function

sub GetUserLicence(docObj)

	If ValidateServer(docObj) = 0 Then
	    msgbox "Server validation failed."
	    exit sub
	End If
	
end sub